package cn.iocoder.yudao.module.pay.splitting.enums;

import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 商户注册的状态枚举
 *
 * @author 山野羡民
 */
@Getter
@AllArgsConstructor
public enum SplittingMerchantStatusEnum implements ArrayValuable<Integer> {

    PENDING(-1, "还未注册"),
    WAITING(0, "等待审核"),
    SUCCESS(1, "注册成功"),
    FAILURE(2, "注册失败"),
    ;

    private final Integer status;
    private final String name;

    @Override
    public Integer[] array() {
        return Arrays.stream(values()).map(SplittingMerchantStatusEnum::getStatus).toArray(Integer[]::new);
    }

    public static SplittingMerchantStatusEnum valueOf(Integer status) {
        for (SplittingMerchantStatusEnum value : values()) {
            if (Objects.equals(value.getStatus(), status)) {
                return value;
            }
        }
        return WAITING;
    }

    /**
     * 判断是否等待审核
     *
     * @param status 状态
     * @return 是否等待审核
     */
    public static boolean isWaiting(Integer status) {
        return Objects.equals(status, WAITING.getStatus());
    }

    /**
     * 判断是否注册成功
     *
     * @param status 状态
     * @return 是否注册成功
     */
    public static boolean isSuccess(Integer status) {
        return Objects.equals(status, SUCCESS.getStatus());
    }

    /**
     * 判断是否注册失败
     *
     * @param status 状态
     * @return 是否注册成功
     */
    public static boolean isFailure(Integer status) {
        return Objects.equals(status, FAILURE.getStatus());
    }

}
